//
//  LogInViewController.m
//  RestaurantCar
//
//  Created by apple on 2017/5/8.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "LogInViewController.h"
#import <SDAutoLayout/UIView+SDAutoLayout.h>

@interface LogInViewController ()
@property (nonatomic,strong) UITextField *userName;
@property (nonatomic,strong) UITextField *passwork;
@property (nonatomic,strong) UIButton *logIn;

@end

@implementation LogInViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor colorWithRed:244/255.0 green:244/255.0 blue:244/255.0 alpha:1];

    [self setNavigationBar];
    [self textFieldAdd];
    [self logInButtonAdd];
    
}
- (void)setNavigationBar {
    self.navigationItem.title = @"登录";
    
    UIButton *goback = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    goback.frame = CGRectMake(0, 11, 10, 20);
    [goback addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    //[goback setImage:[UIImage imageNamed:@"返回-黑色@2x.png"] forState:UIControlStateNormal];
    [goback setBackgroundImage:[UIImage imageNamed:@"返回-黑色@2x.png"] forState:UIControlStateNormal];
    UIBarButtonItem *left = [[UIBarButtonItem alloc] initWithCustomView:goback];
    self.navigationItem.leftBarButtonItem = left;
    
    UIButton *setUp = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    setUp.frame = CGRectMake(0, 2, 60, 40);
    [setUp setTitle:@"注册" forState:UIControlStateNormal];
    [setUp setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [setUp addTarget:self action:@selector(registerConsumer) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithCustomView:setUp];
    self.navigationItem.rightBarButtonItem = right;

}
- (void)textFieldAdd {
    [self.view addSubview:self.userName];
    self.userName.sd_layout.leftSpaceToView(self.view, 30).topSpaceToView(self.view, 114).rightSpaceToView(self.view, 30).heightIs(50);
    // 设置圆角
    self.userName.sd_cornerRadius = [[NSNumber alloc] initWithInt:6];
    
    [self.view addSubview:self.passwork];
    
    self.passwork.sd_layout.leftEqualToView(self.userName).rightEqualToView(self.userName).topSpaceToView(self.userName, 3).heightIs(50);
    // 设置圆角
    self.passwork.sd_cornerRadius = [NSNumber numberWithInt:6];
}
- (void)logInButtonAdd {
    [self.view addSubview:self.logIn];
    self.logIn.sd_layout.leftEqualToView(self.userName).rightEqualToView(self.userName).topSpaceToView(self.passwork, 40).heightIs(50);
    [self.logIn addTarget:self action:@selector(logInUser) forControlEvents:UIControlEventTouchUpInside];
    // 设置圆角
    self.logIn.sd_cornerRadius = [NSNumber numberWithInteger:8];
}

#pragma mark- 返回
- (void)back {
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark- 注册账号
- (void)registerConsumer {
    
}
#pragma mark- 登录
- (void)logInUser {
    
}
- (UITextField *)userName {
    if (_userName == nil) {
        _userName = [[UITextField alloc] init];
        _userName.backgroundColor = [UIColor whiteColor];
        // 提示文字
        _userName.placeholder = @"请输入用户账号";
        _userName.textAlignment = 1;
    }
    return _userName;
}
- (UITextField *)passwork {
    if (_passwork == nil) {
        _passwork = [[UITextField alloc] init];
        _passwork.backgroundColor = [UIColor whiteColor];
        // 提示文字
        _passwork.placeholder = @"请输入密码";
        _passwork.secureTextEntry = YES;
        _passwork.keyboardType = UIKeyboardTypeNamePhonePad;
        _passwork.textAlignment = 1;
    }
    return _passwork;
}
- (UIButton *)logIn {
    if (_logIn == nil) {
        _logIn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        _logIn.backgroundColor = [UIColor colorWithRed:214/255.0 green:129/255.0 blue:30/255.0 alpha:1];
        [_logIn setTitle:@"登 录" forState:UIControlStateNormal];
        _logIn.titleLabel.font = [UIFont systemFontOfSize:20 weight:YES];
        [_logIn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    }
    return _logIn;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
